package com.coffee.order.api.sku.result;

import com.coffee.core.enums.SkuOrderStatusEnum;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

@Data
public class SkuOrderDetailResult implements Serializable {
    private static final long serialVersionUID = -1L;
    private Integer id;
    private Integer skuOrderId;
    private Integer skuId;
    private Integer skuSalesInformationId;
    private String skuSalesInformationName;
    private Integer supplierId;
    private Double price;
    private Double payPrice;
    private Double realityPrice;
    private Integer count;
    private String deliveryWay;
    private String applyRefundStatus;
    private Date applyRefundTime;
    private String applyRefundReason;
    private String refuseRefundReason;
    private Date refundTime;
    private Integer examineId;
    private String examineName;
    private Date examineTime;
    private String isDeliverGoods;
    private String status;
    private String orderStatus;
    private String skuName;
    private String cover;
    private String categoryName;
    private String productName;
    private String specifications;
    private String unit;
    private String postageStatus;
    private String isFreeShipping = "N";
    private String isDirectRefund;
    private Integer postageId;
    private Integer extractSpecifications;
    private String averageSpecifications;
    private Integer periodsNumber;
    private Double modifyPrice;
    private String isModifyPrice;
    private Date modifyTime;

    public void setOrderStatus(String orderStatus) {
        if (SkuOrderStatusEnum.CANCEL.getCode().equals(this.status)) {
            this.orderStatus = SkuOrderStatusEnum.CANCEL.getCode();
        } else if (SkuOrderStatusEnum.WAITING.getCode().equals(this.status)) {
            this.orderStatus = SkuOrderStatusEnum.WAITING.getCode();
        } else if (SkuOrderStatusEnum.PAY.getCode().equals(this.status) && "N".equals(this.isDeliverGoods)) {
            this.orderStatus = SkuOrderStatusEnum.PAY.getCode();
        } else if (SkuOrderStatusEnum.PAY.getCode().equals(this.status) && "Y".equals(this.isDeliverGoods)) {
            this.orderStatus = SkuOrderStatusEnum.DELIVER.getCode();
        } else if (SkuOrderStatusEnum.SUCCESS.getCode().equals(this.status)) {
            this.orderStatus = SkuOrderStatusEnum.SUCCESS.getCode();
        } else if (SkuOrderStatusEnum.PAY.getCode().equals(this.status) && SkuOrderStatusEnum.APPLYING.getCode().equals(this.applyRefundStatus)) {
            this.orderStatus = SkuOrderStatusEnum.APPLYING.getCode();
        } else if (SkuOrderStatusEnum.PAY.getCode().equals(this.status) && SkuOrderStatusEnum.PASS.getCode().equals(this.applyRefundStatus)) {
            this.orderStatus = SkuOrderStatusEnum.PASS.getCode();
        } else if (SkuOrderStatusEnum.PAY.getCode().equals(this.status) && SkuOrderStatusEnum.REFUSE.getCode().equals(this.applyRefundStatus)) {
            this.orderStatus = SkuOrderStatusEnum.REFUSE.getCode();
        }
        this.orderStatus = orderStatus;
    }
}

